<script>
	var url;
	$(document).ready(function(){
		
		loaddata = function(){
			$.ajax({ 
				type: "POST",   
				url: base_url+'penentuan_dosen/getdata',   
				data: $('#form2').serialize(),
				async: true,
				success : function(respon)
				{
					if(respon == ''){
						$('#tbodypendaftar').html('<tr><td align="center" colspan="6">Tidak Terdapat Data Dalam Database</td></tr>');
					}else{
						$('#tbodypendaftar').html(respon);
					}
				}
			});
		}
		
		saveData = function(){
			$('#form2').form('submit',{
				url: base_url+'penentuan_dosen/save',
				onSubmit: function(){
					return $(this).form('validate');
				},
				success: function(result){
					alert(result);
					var result = eval('('+result+')');
					if (result.success){
						$.messager.show({
							title: 'Succes',
							msg: 'Data Berhasil Disimpan'
						});
						$('#tbodypendaftar').html(' ');
					} else {
						$.messager.show({
							title: 'Error',
							msg: result.msg
						});
					}
				}
			});
		}
		//end saveData
		
		// onchange
		$('#s_kd_fakultas').change(function(){
			$('#s_kd_prodi').load(base_url+'prosedur/getProdibyFakultas/'+$('#s_kd_fakultas').val());
		});
		
		// filter
		filter = function(){
			$('#dg').datagrid('load',{
				kd_fakultas : $('#s_kd_fakultas').val(),
				kd_prodi : $('#s_kd_prodi').val(),
				tahun : $('#s_tahun').val(),
			});
			//$('#dg').datagrid('enableFilter');
		}
		
	});
</script>
<form name="form2" id="form2" method="post">
	<table border="0" cellpadding="1" cellspacing="1" width="100%">
					<tr>
						<td>
						<div class="fsearch">
							<table border="0" cellpadding="1" cellspacing="1">
								<tr>
									<td>Fakultas</td>
									<td>: 
										<select id="s_kd_fakultas" name="s_kd_fakultas" style="width:290px;">
											<?=$this->mdl_prosedur->OptionFakultas();?>
										</select>
									</td>
									<td>&nbsp;</td>
									<td>Tahun Angkatan</td>
									<td>: 
										<select id="s_tahun" name="s_tahun" style="width:100px;">
											<?=$this->mdl_prosedur->OptionTahunAngkatan();?>
										</select>
									</td>
								</tr>
								<tr>
									<td>Program Studi</td>
										<td>: 
											<select id="s_kd_prodi" name="s_kd_prodi" style="width:290px;">
												<?=$this->mdl_prosedur->OptionProdi();?>
											</select>
										</td>
										
										<td>&nbsp;</td>
										<td><a href="#" class="easyui-linkbutton" onclick="loaddata();" iconCls="icon-reload" plain="true">Tampilkan</a></td>
										<td>&nbsp;&nbsp;</td>
								</tr>
						<td align="left" colspan="2" valign="top">
						</td>
					</tr>
				</table>
			</div>
			</td>
		</tr>
	</table>
	<div class="fsearch" style="padding:3px 0px 3px 10px">
		
			<label style="width:75px">Dosen Wali </label>: 
			<select name="kd_dosen" id="kd_dosen" style="width:280px;">
				<?=$this->mdl_prosedur->OptionDosenWali();?>
			</select>
		
	</div>
	

	<table class="tbl">
		<thead>
			<tr>
				<th width="20px" bgcolor="#F4F4F4">No.</th>
				<th width="18px" bgcolor="#F4F4F4"></th>
				<th width="" bgcolor="#F4F4F4">NIM</th>
				<th width="" bgcolor="#F4F4F4">Nama</th>
				<th width="" bgcolor="#F4F4F4">Program Studi</th>
			</tr>
		</thead>
		<tbody id="tbodypendaftar">
			
		</tbody>
	</table>
	<br>
	<div align="right"><a href="#" class="easyui-linkbutton" onclick="saveData();" iconCls="icon-save" plain="false">Simpan</a>&nbsp;&nbsp;&nbsp;</div>
</form>